#include "header.h"
#include <fstream>

using namespace std;

int main()
{
  string alg = "hmc";

  if(alg == "hmc")
  {
    int d_seed;                 // seed for random number
    double d_TempStart, d_TempStep, d_TempEnd;
    double d_SuccessRatio;
    int d_StepNumber;           // Nmd
    int d_NSample;	            // Nmc number of samples for each run
    double d_StepLength;        // = 0.01; //1e-2;
    int NEachTempRun;           // number of runs for each temperature
    int d_N;                    // number of degrees of freedom
    double nRun;
    double nStep;


    ifstream inputFile("../HMC_core/input/params_hmc.txt");

    if (! inputFile)
    {
      cout << "Cannot open params.in\n";
      exit(1);
    }

    inputFile >> d_seed >> d_TempStart >> d_TempStep
        >> d_TempEnd >> d_SuccessRatio >> d_StepNumber >> d_NSample 
        >> d_StepLength >> NEachTempRun >> d_N;

    inputFile.close();

    if (d_TempStart != d_TempEnd)
    {
      nStep = (d_TempEnd - d_TempStart) / d_TempStep;
      nRun = nStep * NEachTempRun;
    }
    else
    {
      nStep = 0.0;
      nRun = NEachTempRun;
    }

    //string directoryB2 = "B2";
    //string directoryGrie = "Griewank";
    //string directoryRosen = "Rosenbrock";
    string directoryShek = "Shekel";
    //string directoryZak = "Zakharov";

    //createForEachRun(nRun, NEachTempRun, directoryB2);
    //createForEachRun(nRun, NEachTempRun, directoryGrie);
    //createForEachRun(nRun, NEachTempRun, directoryRosen);
    createForEachRun(nRun, NEachTempRun, directoryShek);
    //createForEachRun(nRun, NEachTempRun, directoryZak);
  }

  //alg = "cts";

  if(alg == "cts")
  {
    int d_seed;                 // seed for random number
    int d_numNeighPoint;        // number of neighbouring solutions
    double d_radiusTabuSphere;  // radius of the tabu hypersphere
    double d_biggestRadius;     // radius of the biggest hypersphere
    int d_maxTabuListSize;      // size of the tabu list  
    int numRun;                 // number of runs
    int d_numDim;	              // the number of dimensions
    int d_maxIteration;         // max number of iterations

    ifstream inputFile("../HMC_core/input/params_cts.txt");

    if (! inputFile)
    {
      cout << "Cannot open params.in\n";
      exit(1);
    }

    inputFile >> d_seed >> d_numNeighPoint >> d_radiusTabuSphere
      >> d_biggestRadius >> d_maxTabuListSize >> numRun >> d_numDim >> d_maxIteration;

    inputFile.close();

    string directoryB2 = "B2";
    //string directoryGrie = "Griewank";
    string directoryRosen = "Rosenbrock";
    //string directoryShek = "Shekel";
    //string directoryZak = "Zakharov";

    createForEachRun(numRun, directoryB2);
    //createForEachRun(numRun, directoryGrie);
    createForEachRun(numRun, directoryRosen);
    //createForEachRun(numRun, directoryShek);
    //createForEachRun(numRun, directoryZak);

  }

  return 0;
}